# Use the cartography library to do the choropleth map
install.packages("cartography")
library(cartography)

# Load data
data(nuts2006)

# Build a choropleth
map_2025<-read.csv(file.choose())

# Figure 1
choroLayer(spdf = nuts2.spdf, df = map_2025, var = "Popvote" , legend.pos = "right", method = "quantile", nclass = 8
          , col = carto.pal(pal1 = "brown.pal", n1 = 8),
           border = "grey40",
           legend.values.rnd = 2)
title("Populist Support in 11 European Countries (2002-2017)")

# Figure A1
choroLayer(spdf = nuts2.spdf, df = map_2025, var = "Importshock" , legend.pos = "right", method = "quantile", nclass = 8
           , col = carto.pal(pal1 = "red.pal", n1 = 8),
           border = "grey40",
           legend.values.rnd = 2)
title("China Import Shock in 11 European Countries (2002-2017)")

# Figure A2
choroLayer(spdf = nuts2.spdf, df = map_2025, var = "Incongruence" , legend.pos = "right", method = "quantile", nclass = 8
           , col = carto.pal(pal1 = "blue.pal", n1 = 8),
           border = "grey40",
           legend.values.rnd = 2)
title("Ideological Incongruence in 11 European Countries (2002-2017)")
